package com.itheima.controller;


import com.itheima.common.PageBean;
import com.itheima.common.R;
import com.itheima.domain.dto.ArraySLists;
import com.itheima.domain.pojo.TCustomer;
import com.itheima.service.TCustomerSerevce;
import com.itheima.service.YCheckItemSeverl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.regex.Pattern;

/**
 * 客户会员
 * @CrossOrigin:是为了解决前端请求后端发生跨域
 */
@RestController
@RequestMapping("customer")
@CrossOrigin
@Api(tags = "VIP数据管理")
public class TCustomerController {
    @Autowired
    private TCustomerSerevce tCustomerSerevce;

    @GetMapping("/pageQuery")
    @ApiOperation("带条件分页查询")
    public R selectAll(@RequestParam(defaultValue = "1") @ApiParam(name = "page",value = "第几页") Integer page, @RequestParam(defaultValue = "10") @ApiParam(name = "size",value = "每页数据") Integer size, @ApiParam(name = "name",value = "姓名") String name,@ApiParam(name = "phone",value = "电话号码") String phone, @ApiParam(name = "gender",value = "性别") Short gender,
                       @ApiParam(name = "beginTime",value = "开始时间") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginTime,
                       @ApiParam(name = "endTime",value = "结束时间")  @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endTime
                       ) {
        PageBean pageBean = tCustomerSerevce.selectAll(page, size,name,phone,gender,beginTime,endTime);
        return R.ok(pageBean);
    }

    @GetMapping("/ageReport")
    @ApiOperation("统计查询")
    public R s1() {
        ArraySLists arraySLists = tCustomerSerevce.s1();
        return R.ok(arraySLists);
    }
}

